﻿#include "formabout.h"
#include "ui_formabout.h"
#include <appbase.h>

#include <QFile>
#include <QTextStream>


FormAbout::FormAbout(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormAbout)
{
    ui->setupUi(this);

    /*
     * 界面布局
     * */
    setFixedSize(420,325);


    /*
     * 控件初始化
     * */
    ui->label_1->setAlignment(Qt::AlignCenter);
    ui->label_2->setAlignment(Qt::AlignCenter);
    ui->label_3->setAlignment(Qt::AlignCenter);
    ui->label_4->setAlignment(Qt::AlignCenter);

    /*
     * 中文转码处理 与 初始化
     * */
    ChMSTextCodec ChMSTc;
    ChMSVersion ChMSV;

    QByteArray varQLabel_2 = "基于QT5.15.2开发";
    QByteArray varQLabel_3 = "版本: ";
    QByteArray varQLabel_4 = "作者：";
    QByteArray varQPusBut_1 = "关闭";
    QByteArray varWindowTitle = "关于";

    QString varUnicodeTmp1 = ChMSTc.funQStrTextCodec(ChMSV.ProName);
    QString varUnicodeTmp2 = ChMSTc.funQStrTextCodec(varQLabel_2);
    QString varUnicodeTmp3 = ChMSTc.funQStrTextCodec(varQLabel_3.append(ChMSV.Version));
    QString varUnicodeTmp4 = ChMSTc.funQStrTextCodec(varQLabel_4.append(ChMSV.Author.append("  ").append(ChMSV.Email)));
    QString varUnicodeTmp5 = ChMSTc.funQStrTextCodec(varQPusBut_1);
    QString varUnicodeTmp6 = ChMSTc.funQStrTextCodec(varWindowTitle);


    setWindowTitle(varUnicodeTmp6);
    ui->label_1->setText(varUnicodeTmp1);
    ui->label_2->setText(varUnicodeTmp2);
    ui->label_3->setText(varUnicodeTmp3);
    ui->label_4->setText(varUnicodeTmp4);
    ui->pushButton->setText(varUnicodeTmp5);

    /*
     * 读取 qss 皮肤文件
     * */
    QFile objFileSkin(":/res/Style/about.qss");
    QString varQStrSkin;
    if(objFileSkin.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QTextStream qssInput(&objFileSkin);
        while(!qssInput.atEnd())
        {
            varQStrSkin += qssInput.readLine();
        }
    }
    objFileSkin.close();
    this->setStyleSheet(varQStrSkin);

    /*
     * 信号 槽
     * */

    connect(ui->pushButton,&QPushButton::clicked,this,&FormAbout::on_pushButton_clicked);
}

FormAbout::~FormAbout()
{
    delete ui;
}

void FormAbout::on_pushButton_clicked()
{
    FormAbout::close();
}
